package com.cs.common.init;

import java.util.HashMap;

import com.cs.common.init.beans.PermissionBean;

/**
 * Sysmte Parameters collection
 * @version 1.0 
 * @date  2009-12-10
 * @author Administrador
 */

public class PermissionCollection extends HashMap implements IInit {
	/** Serialization UID */
	private static final long serialVersionUID = 3448825480194875467L;
	/** Class instance */
	private static PermissionCollection permissionCollection = null;
	/**
	 * Gets class instance filled
	 */
	public static PermissionCollection getInstance(){
		return permissionCollection;
	}
	/**
	 * Loads the xml file into class
	 * @param object Object to load
	 */
	public void init(Object object) {
		if( object != null ){
			if( object instanceof PermissionCollection){
				permissionCollection = (PermissionCollection) object;
			}
		}
	}
	/**
	 * Add PermissionBean to the collection
	 * @param permissionBean
	 */
	public void addPermissionBean( PermissionBean permissionBean ){
		this.put(permissionBean.getAction(), permissionBean);
	}
	/**
	 * Gets permission bean
	 * @param action name
	 * @return PermissionBean
	 */
	public PermissionBean getPermissionBean(String name){
		PermissionBean permissionBean = null;
		permissionBean = (PermissionBean)this.get(name);
		return permissionBean;
	}
}